package edu.infomatik.tundra.model;

import org.apache.tapestry5.ValueEncoder;

import edu.infomatik.tundra.data.DAOtundra;
import edu.infomatik.tundra.logic.WorkBean;

public class ProjectIdEncoder implements ValueEncoder<WorkBean> {
	
	@Override
	public String toClient(WorkBean value) {
		return ""+value.getId();
	}

	@Override
	public WorkBean toValue(String clientValue) {
		if (null!=clientValue){
			WorkBean wb = new WorkBean();
			wb.setId(Long.parseLong(clientValue));
			return (WorkBean)DAOtundra.getInstance().getBeanById(wb);
		}
		return new WorkBean();
	}

}
